<%@ page import="java.sql.ResultSet" %>
<%@ page import="java.sql.Statement" %>
<%@ page import="java.sql.Connection" %>
<%@ page import="com.wyj.db.DBConnection" %>

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
    Connection conn = DBConnection.getConnection();
    Statement statement = conn.createStatement();
    String sql = "SELECT * FROM BookInfo";
    ResultSet rs = statement.executeQuery(sql);
%>
<html>
<head>
    <title>鸽鸽书后台管理系统</title>
    <link rel="stylesheet" href="css/bootstrap3.3.7.min.css">
    <link rel="stylesheet" href="css/index.css">
    <script src="js/jquery-3.2.0.min.js"></script>
    <script src="js/bootstrap3.3.7.min.js"></script>
    <script src="js/functions.js"></script>


</head>
<body>
<div class="row title">
    <div class="col-md-12 text-center title">
        <a href="https://55300249.qcloud.la/PPBManager/index.jsp">
            <h1>鸽鸽书后台管理系统</h1>
        </a>
    </div>
</div>

<div class="row navbar">
    <div class="col-md-6 col-md-offset-4 nav text-center">
        <jsp:include page="nav.jsp"></jsp:include>
    </div>
</div>

<div class="content">
    <div class="row student">
        <div class="col-md-12 text-center">
            <button class="btn btn-success" onclick="$('tr.insert').show()">上架</button>
            <button class="btn btn-info" onclick="location.reload()">刷新</button>
            <table class="table table-striped">
                <caption>馆内藏书</caption>
                <thead>
                <tr>
                    <th>馆内编号</th>
                    <th>isbn</th>
                    <th>入馆时间</th>
                    <th>位置</th>
                    <th>是否在馆内</th>
                </tr>
                </thead>
                <tbody>
                <div class="insertbox">
                    <form class="form-inline insert" role="form" action="servlet/InsertServlet" method="post" >
                        <tr class="insert" hidden>
                                <input class="header" type="text" name="student" hidden>
                                <td><input type="text" class="form-control" name="bookId" ></td>
                                <td><input type="text" class="form-control" name="isbn10"></td>
                                <td><input type="text" class="form-control" name="entryTime" ></td>
                                <td><input type="text" class="form-control" name="location"></td>
                                <td><input type="text" class="form-control" name="existed"></td>
                                <td><button type='submit' class="btn btn-success" >提交</button></td>

                            <td><button type='button' class="btn btn-default" onclick="location.reload();">删除</button></td>
                        </tr>
                    </form>
                </div>
                <%
                    while (rs.next()) {
                %>
                <tr>
                    <td><%out.print(rs.getString(1));%></td>
                    <td><%out.print(rs.getString(2));%></td>
                    <td><%out.print(rs.getString(3));%></td>
                    <td><%out.print(rs.getString(4));%></td>
                    <td><%out.print(rs.getString(5));%></td>
                    <td><button type="button" class="btn btn-danger" onclick="deleteRow('student','studentnum',$(this).parent().parent().children().first().text());location.reload();">下架</button></td>

                </tr>
                <%
                    }
                %>
                </tbody>
            </table>
        </div>
    </div>


</div>
</body>
</html>